if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CleanupOldLoginSessions]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[CleanupOldLoginSessions]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO


/*
	version: 1.0
	by: MAC
	date: 2008/03/30
	description:
	
	Initial creation
*/

CREATE          PROCEDURE CleanupOldLoginSessions
	(
		@MinutesExpiry INT = 180 -- default 3hrs
	)
AS
	
	DELETE 
	FROM LoginSession
	WHERE (DATEDIFF(mi, LastActivity, GETDATE())) > @MinutesExpiry	
	


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

